﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Radiation.Common
{
    public class GenericEventArgs : EventArgs
    {
        private object[] _values;
        private int _counter;
        private string[] _keys;

        public object this[string name]
        {
            get
            {
                for (int i = 0; i < this._counter; i++)
                {
                    if (_keys[i] == name)
                    {                        
                        return this._values[i];
                    }
                }

                return null;
            }
            set
            {
                bool found = false;
                int f_index = 0;

                for (int i = 0; i < this._counter; i++)
                {
                    if (_keys[i] == name)  
                    {
                        found = true;
                        f_index = i;
                        break;
                    }
                }

                if (!found)
                {
                    this._keys[this._counter] = name;
                    this._values[this._counter] = value;
                    this._counter++;
                }
                else
                    this._values[f_index] = value;
            }
        }

        public object this[int index]
        {
            get
            {
                if (index >= 0 && index < this._counter)
                    return this._values[index];
                return null;
            }
            /*set
            {
                if (index >= 0 && index < this._counter)
                    this._values[index] = value;
            }*/
        }

        public GenericEventArgs()
        {
            this._keys = new string[10];
            this._values = new object[10];
            this._counter = 0;
        }
    }
}
